package cn.keniykey.mc.landterritory.landview;

import java.util.List;

import javax.annotation.Nullable;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import cn.keniykey.mc.landterritory.LandTerritoryMain;
import cn.keniykey.mc.landterritory.config.ViewsConfiguration;
import cn.keniykey.mc.landterritory.toolkit.Util;
import cn.keniykey.mc.viewlibrary.container.api.EContainerType;
import cn.keniykey.mc.viewlibrary.view.api.template.AbChooseView;

public final class LandChooseView extends AbChooseView{
	private static final String VIEW_NAME = "choose";
	private static final AbChooseMenuViewIconsGrid ICONSGRID = new AbChooseMenuViewIconsGrid() {
		@Override
		protected int getGridOfCancel() {
			return ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItemSlot("cancel");
		}
		@Override
		protected int getGridOfConfirm() {
			return ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItemSlot("confirm");
		}
		@Override
		protected int getGridOfCountdown() {
			return ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItemSlot("countdown");
		}
		@Override
		protected int getGridOfPrompt() {
			return ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItemSlot("prompt");
		}
		@Override
		protected int getGridOfVeto() {
			return ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItemSlot("veto");
		}
	};
	
	protected LandChooseView(Player player1) {
		super(LandTerritoryMain.getPlugin(), player1);
	}

	@Override
	protected AbChooseMenuViewIconsGrid getDeafultIconsGrid() {
		return ICONSGRID;
	}

	@Override
	protected ItemStack onDeafultIconOfCancel(@Nullable Material type) {
		final ItemStack item = ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItem("cancel");
		if(type != null) item.setType(type);
		return item;
	}

	@Override
	protected ItemStack onDeafultIconOfConfirm(@Nullable Material type) {
		final ItemStack item = ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItem("confirm");
		if(type != null) item.setType(type);
		return item;
	}

	@Override
	protected ItemStack onDeafultIconOfCountdown(@Nullable Material type) {
		final ItemStack item = ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItem("countdown");
		if(type != null) item.setType(type);
		return item;
	}

	@Override
	protected ItemStack onDeafultIconOfPrompt(@Nullable Material type, String str, @Nullable List<String> lore) {
		final ItemStack item = ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItem("prompt");
		if(type != null) item.setType(type);
		return ViewsConfiguration.setItemMeta(item, str, lore);
	}

	@Override
	protected ItemStack onDeafultIconOfVeto(@Nullable Material type) {
		final ItemStack item = ViewsConfiguration.getViewConfig(VIEW_NAME).getViewItem("veto");
		if(type != null) item.setType(type);
		return item;
	}

	@Override
	protected EContainerType onDefaultEViewType() {
		return EContainerType.matchContainer(ViewsConfiguration.getViewConfig(VIEW_NAME).getViewSize());
	}
	
	@Override
	protected String onDefaultTitle() {
		return Util.conver(ViewsConfiguration.getViewConfig(VIEW_NAME).getViewTitle());
	}
}